﻿// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone

using BlazorAdmin.Models;
using BlazorAdmin.Interface;
using System;
using BlazorAdmin.Services.DbService;

namespace BlazorAdmin.Services
{
    internal class LoginService : BaMgmtDbService, ILogin
    {
        public LoginService(IPetaPoco database) : base(database) { }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="IP"></param>
        /// <param name="OS"></param>
        /// <param name="browser"></param>
        /// <param name="address"></param>
        /// <param name="userAgent"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public bool Log(string userName, string IP, string OS, string browser, string address, string userAgent, bool result)
        {
            var loginUser = new LoginLog()
            {
                UserName = userName,
                LogTime = DateTime.Now,
                IP = IP,
                City = address,
                OS = OS,
                Browser = browser,
                UserAgent = userAgent,
                Result = result ? "登录成功" : "登录失败"
            };
            Insert(loginUser);
            return true;
        }
    }
}